home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2074 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.8 KB  |  70 lines

  1. Path: news.lpr.carel.fi!usenet
  2. From: aril@cmt.lpr.mail.carel.fi (Ari Lukumies)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: assembly lang. and Borland C++
  5. Date: Mon, 15 Jan 1996 10:31:43 GMT
  6. Organization: Carelcomp Forest Oy
  7. Message-ID: <4ddas3$di6@tahko.lpr.carel.fi>
  8. References: <4d5q0m$926@news.rwth-aachen.de>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. ILT-Benutzer <user@ilt.fhg.de> wrote:
  13.  
  14. [stuff deleted]
  15. >But I need the opposite of this. The assembly language module shall
  16. >call a C++routine.
  17.  
  18. >I tried the following:
  19.  
  20. >C++ Modul:
  21. >--------------------------------------
  22. >..
  23. >void CProzedur()
  24. >{
  25. > ...
  26. >}
  27. >..
  28. >--------------------------------------
  29.  
  30. >and in assembymodul:
  31. >--------------------------------------
  32. >..
  33. >extrn _CProzedur:far
  34. >..
  35. >..
  36. >call _CProzedur  ; call the CRoutine 
  37. >--------------------------------------
  38.  
  39. >If I compile it as C (C-module has extension .C) code no error appears.
  40. >But if I switch the key Options|compiler|C++options to
  41. >CPP always the Linker says something like:
  42. >Can┤t find _CProzedur ...
  43.  
  44. >So, I have to tell the assembler that it has to generate C++ Code.
  45. >But how ???
  46.  
  47. When you compile CPP code, the compiler mangles the function names (it
  48. will attach runtime type information to the function name, such as the
  49. return type and types of parameters). So, the name will not look like
  50. you'd expect to your assembly code. For instance, if you have a class
  51. CBase with a default constructor:
  52.  
  53.   CBase::CBase() { }
  54.  
  55. the name that the compiler will give to compiled function will be
  56. something like:
  57.  
  58.   ??0CBase@@REC@XZ
  59.  
  60. So, in order to call the function from assembly code, you'll need to
  61. find out how your C++ compiler generates those mangled (or decorated,
  62. if you'd prefer) names. This information is usually included with your
  63. compiler's documentation.
  64.  
  65. Later,
  66. AriL
  67.  
  68. All my opinions are mine and mine alone.
  69.  
  70.